package models

import (
	"github.com/astaxie/beego/orm"
)

//用户信息表
type Image struct {
	Id      int
	Format  string `orm:"size(10)"`
	Content string `orm:"null,type(text)"`
}

func init() {
	// 需要在init中注册定义的model
	orm.RegisterModel(new(Image))
}

func GetSculpture(imageId int) (*Image, error) {
	image := new(Image)
	image.Id = imageId
	if err := dataOrm.Read(image); err != nil {
		return nil, err
	}
	return image, nil
}

func AddSculpture(image *Image) (*Image, error) {
	if _, err := dataOrm.Insert(image); err != nil {
		return nil, nil
	}
	return image, nil
}

func DelSculpture(imageId int) {
	if imageId != -1 {
		dataOrm.Delete(&Image{Id: imageId})
	}
}
